package sum.book.common.core.model.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import sum.book.common.core.constant.ICodeEnum;

import java.io.Serializable;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class RestDTO implements Serializable {
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = -3462433258560124278L;
    /**
     * 响应代码
     */
    private String code;

    /**
     * 成功标示
     */
    private Boolean success;

    /**
     * 响应代码说明
     */
    private String msg;

    /**
     * 流水号
     */
    private String serno;


    /**
     * 构造函数，所有的错误编码枚举需要实现BaseCode接口
     *
     * @param codeEnum
     */
    public RestDTO(ICodeEnum codeEnum) {
        this.code = codeEnum.code();
        this.success = codeEnum.success();
        this.msg = codeEnum.message();
    }

    /**
     * 构造函数，所有的错误编码枚举需要实现BaseCode接口,使用自定义的消息
     *
     * @param codeEnum
     */
    public RestDTO(String message, ICodeEnum codeEnum) {
        this.code = codeEnum.code();
        this.success = codeEnum.success();
        this.msg = message;
    }

    /**
     * 构造函数，所有的错误编码枚举需要实现BaseCode接口,使用自定义的消息
     *
     * @param codeEnum
     */
    public RestDTO(String serno,String message, ICodeEnum codeEnum) {
        this.code = codeEnum.code();
        this.success = codeEnum.success();
        this.msg = message;
        this.serno = serno;
    }
}
